/**
 * @Author: Lenovo
 * @Date: 2024/11/7 9:35
 * @description:
 */
class MyThread extends Thread{
    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Hello thread!");
        }
    }
}
public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
        // 方法一：创建一个 MyThread 类继承 Thread，重写 run 方法
        Thread thread = new MyThread();
        thread.start();
        //thread.run();
        while (true){
            System.out.println("Hello main");
            Thread.sleep(1000);
        }
    }
}
